<style lang="less" scoped>
@import url('./style.less');
.list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  &-item {
    flex: 0 0 50%;
    display: flex;
    align-items: center;
    margin-bottom: 10px;

    .icon {
      width: 14px;
      height: 14px;
    }
    .name {
      margin-right: 5px;
      margin-left: 5px;
    }
    .job {
      color: #999;
    }
  }
}
</style>
<template>
  <div class="box">
    <div class="box-title" @click="show=!show">
      <div class="box-title__label">主要人员历史快照</div>
      <div class="box-title__right">
        <span class="num">{{len||'无'}}</span>
        <i :class="cls"></i>
      </div>
    </div>
    <div class="box-content" v-show="show">
      <div class="panel">
        <div class="panel-content" v-if="len>0">
          <div class="step" v-for="(item, index) in dt" :key="index">
            <div :class="['step-content',{active:index==0}]">
              <div class="step-item">
                <div class="step-label">{{item.ChangeDate||'-'}}</div>
                <div class="step-value list">
                  <div class="list-item" v-for="(item1, index1) in item.Employees" :key="index1">
                    <image v-if="item1.avatar" class="icon" :src="item1.avatar" />
                    <avator v-else :text="item1.EmployeeName" :h="28" :fs="20" radius="5rpx" />
                    <div class="name c-primary" @click="itemClick(item1)">{{item1.EmployeeName||'-'}}</div>
                    <div class="job" v-if="item1.Job">({{item1.Job}})</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Avator from '@/components/textToAvator';
export default {
  components: { Avator },
  props: ['dt'],
  data() {
    return {
      show: false
    };
  },
  onUnload() {
    this.show = false;
  },
  computed: {
    cls() {
      const arrow = this.show ? 'icon-shangjiantou' : 'icon-tubiaozhizuo-';
      return `iconfont ${arrow}`;
    },
    len() {
      let tmp = 0;
      try {
        tmp = this.dt.length;
      } catch (error) {}
      return tmp;
    }
  },
  methods: {
    itemClick(item) {
      // 法人
      const Oper = {
        Name: item.EmployeeName,
        KeyNo: item.KeyNo
      };
      this.$router.push({
        path: '/pages/base/faren/main',
        query: {
          Oper: JSON.stringify(Oper)
        }
      });
    }
  }
};
</script>
